package object5.library;

public class BookList {
    private Book[] books = new Book[1024];
    //最多能存放的书的数量
    private int size = 0;
    //实际存放的书籍的数量

    public BookList(){
        //默认填写几本书,方便后面的测试,可以直接测试打印书籍,不用等到存入书籍操作写出
        books[0] = new Book("西游记","吴承恩",38,"古典小说");
        books[1] = new Book("教父","奥斯特",49,"黑帮小说");
        books[2] = new Book("Java入门","詹姆斯高斯林",99,"计算机");
        books[3] = new Book("高等数学","牛顿",12,"数学");
        books[4] = new Book("西游记","吴承恩",38,"古典小说");
        size = 5;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    //自动生成的getter,setter,是针对整个数组来进行的
    //这里的预期是针对某个数组元素的getter和setter.
//    public Book[] getBooks() {
//        return books;
//    }
//    public void setBooks(Book[] books) {
//        this.books = books;
//    }

//针对一本书进行操作,故Book是单数
    public Book getBook(int index){
        return books[index];
    }
    public void setBook(int index,Book book){
        books[index] = book;
    }


}
